package com.ruoyi.framework.config;

import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author jll
 * @createTime 2025/6/13
 * @description Sa-Token 配置
 * @version: 1.0
 */
@Configuration
public class SaTokenConfig implements WebMvcConfigurer {
    /**
     * 注册 Sa-Token 拦截器，打开注解式鉴权功能
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册Sa-Token的路由拦截器
        registry.addInterceptor(new SaRouteInterceptor())
                // 拦截 APP或小程序的 所有请求
                .addPathPatterns("/api/**")
                // 排除 APP或小程序的 认证授权请求，如登录等
                .excludePathPatterns("/api/auth/**");
    }
}
